<?php
// <standard:foreach var="EXPRESSION" key="VARNAME" value="VARNAME">BODY</standard:foreach>
class StandardForeachTag extends AbstractTag {
	public function parseStartTag($tblParameters=array()) {
		$this->checkParameters($tblParameters, array("var","value"));
		if(!$this->isExpression($tblParameters['var'])) throw new ViewException("Value 'var' must be an expression for ".get_class($this)."!");
		return '<?php foreach('.$this->parseExpression($tblParameters['var']).' as '.($tblParameters['key']?'$'.$tblParameters['key'].'=>':'').'$'.$tblParameters['value'].') { ?>';
	}
	
	public function parseEndTag() {
		return '<?php } ?>';
	}
}